package com.aspsine.multithreaddownload.util;

import ohos.app.Context;
import ohos.app.Environment;

import java.io.File;

/**
 * Created by aspsine on 15-4-19.
 */
public class FileUtils {
    private static final String DOWNLOAD_DIR = "download";

    //TODO hos 中没有MEDIA_MOUNTED字段，暂时这么处理
    public static final File getDefaultDownloadDir(Context context) {

       // if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
          //  return new File(context.getExternalCacheDir(), DOWNLOAD_DIR);
       // }
        return new File(context.getCacheDir(), DOWNLOAD_DIR);
    }

    public static boolean isSDMounted(){ //TODO hos 中没有MEDIA_MOUNTED字段，暂时这么处理
       // return Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED);
        return true;
    }

    public static final String getPrefix(String fileName) {
        return fileName.substring(0, fileName.lastIndexOf("."));
    }

    public static final String getSuffix(String fileName) {
        return fileName.substring(fileName.lastIndexOf(".") + 1);
    }
}
